<template>
  <div id="app">
    <ul>
      <li v-for="(item, index) in list" :key="index">
        {{ item }} <span @click="del(index)">删除</span>
      </li>
    </ul>

    <button @click="fn">生成</button>
  </div>
</template>

<script>
export default {
  name: 'App',
  data() {
    return {
      list: []
    }
  },
  methods: {
    fn() {
      const res = Math.floor(Math.random() * 21)
      this.list.push(res)
    },
    del(index) {
      this.list.splice(index,1)
    }
  }
}
</script>

<style scoped>
body {
  background-color: #ccc;
}

#app {
  width: 400px;
  margin: 20px auto;
  background-color: #fff;
  border: 4px solid blueviolet;
  border-radius: 1em;
  box-shadow: 3px 3px 3px rgba(0, 0, 0, 0.5);
  padding: 1em 2em 2em;
}

#app h3 {
  text-align: center;
}

.title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid #ccc;
  padding: 0 1em;
}

.title h4 {
  line-height: 2;
  margin: 0;
}

.container {
  border: 1px solid #ccc;
  padding: 0 1em;
}

.btn {
  /* 鼠标改成手的形状 */
  cursor: pointer;
}
</style>
